package oocl.ita.eordering.webService;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import javax.ws.rs.core.MediaType;

import org.springframework.beans.factory.annotation.Autowired;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;

import oocl.ita.eordering.po.Merchant;
import oocl.ita.eordering.service.MerchantService;

public class GetMerchantStatusWS {
	
	private static Properties prop = new Properties();
	
	public static int getMechantPass(Merchant merchant) {
		Client client = Client.create();
		client.setReadTimeout(1000);
		
		try {
			prop.load(new FileInputStream(GetMerchantStatusWS.class.getClassLoader().getResource("ws.properties").getPath()));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String url = prop.getProperty("statUrl");
		WebResource wr = client.resource(url + merchant.getmId());
//		WebResource wr = client.resource("http://10.222.232.155:8080/ita_project4_admin/merchant/get/status/"+merchant.getmId());
		String mStatusId = wr.queryParam("mId", merchant.getmId().toString())
				.accept(MediaType.APPLICATION_JSON_TYPE)// accept请求头
				.get(String.class);
		int mStatusIdint = Integer.parseInt(mStatusId);
			System.out.println("mStatusIdint is ..." + mStatusIdint);
		return mStatusIdint;
		
	}
}
